/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is MaoBot.
 *
 * The Initial Developer of the Original Code is NoobSauce <tvilece@gmail.com>.
 * Portions created by NoobSauce are Copyright (C) 2011 NoobSauce. All Rights Reserved.
 *
 * Contributor(s):
 * tankgunk <tankgunk@gmail.com>
 *
 * ***** END LICENSE BLOCK ***** */
package org.maobot;

public class Card {
	enum Suit {CLUBS, DIAMONDS, HEARTS, SPADES, JOKER;
		public int num(){
			switch(this){
			default: return 4;
			case CLUBS: return 0;
			case DIAMONDS: return 1;
			case HEARTS: return 2;
			case SPADES: return 3;
			case JOKER: return 4;
			}
		}
		public static Suit rev(int n){
			switch(n){
			default: return JOKER;
			case 0: return CLUBS;
			case 1: return DIAMONDS;
			case 2: return HEARTS;
			case 3: return SPADES;
			}
		}
	}
	public static int CSeed(){
		return (int)(Math.random() * 54) + 1;
	}
	enum Value {ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, JOKER;
			public int num(){
			switch(this){
			default: return 0;
			case ACE: return 1;
			case TWO: return 2;
			case THREE: return 3;
			case FOUR: return 4;
			case FIVE: return 5;
			case SIX: return 6;
			case SEVEN: return 7;
			case EIGHT: return 8;
			case NINE: return 9;
			case TEN: return 10;
			case JACK: return 11;
			case QUEEN: return 12;
			case KING: return 14;
			}
		}
		public static Value rev(int n){
			switch(n){
			default: return JOKER;
			case 1: return ACE;
			case 2: return TWO;
			case 3: return THREE;
			case 4: return FOUR;
			case 5: return FIVE;
			case 6: return SIX;
			case 7: return SEVEN;
			case 8: return EIGHT;
			case 9: return NINE;
			case 10: return TEN;
			case 11: return JACK;
			case 12: return QUEEN;
			case 13: return KING;
			}
		}
	}
	
	int seed;
	Suit suit;
	Value value;
	void print(){
		System.out.println(value + " of " + suit);
	}
	void ePrint(){
		System.out.println("The" + value + "of" + suit);
	}
	Card(){
		seed = CSeed();
		suit = Suit.rev((seed)/13);
		value = Value.rev(seed%13 + 1);
	}
	Card(int seed){
		this.seed = seed;
		suit = Suit.rev((seed)/13);
		value = Value.rev(seed%13 + 1);
	}
	Card(Suit s, int v){
		suit = s;
		value = Value.rev(v);
		seed = (suit.num() * 13) + (value.num());
	};
	Card(int s, int v){//Jokers are 0,1 and 0,2 (cards 53 and 54, the black and red jokers.)
		suit = Suit.rev(s);
		seed = (s * 13) + (value.num());
	}
}
